<?php
/**
 * Project: AIGC
 * Author: moufer <moufer@163.com>
 * Date: 2024/7/6 23:41
 */

namespace module\ai\library\channel\llm;

use module\ai\library\channel\exception\CompletionException;

class BaiduErnieSpeed extends BaiduErnieLite
{
    /**
     * @inheritdoc
     */
    public static function versions(): array
    {
        return [
            '8k'   => 'ERNIE-Speed-8K',
            '128k' => 'ERNIE-Speed-128K',
        ];
    }

    /**
     * @inheritdoc
     */
    public function getEndPoint(): ?string
    {
        $model = empty($this->config['model']) ? '8k-0922' : $this->config['model'];
        if (!isset(static::versions()[$model])) {
            throw new CompletionException('未定义百度千帆模型');
        }

        return match ($model) {
            '8k' => 'ernie_speed',
            '128k' => 'ernie-speed-128k',
            default => null
        };
    }

}